package com.esiag.loadbalancer.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.esiag.pdsteam.loadbalancer.ISubscriber;

public class Subscriber<TEntity> implements ISubscriber<TEntity> {
	
	private List<TEntity> mTails = Collections.synchronizedList(new ArrayList<TEntity>());
	
	public void subscribe(TEntity pTail) {
		synchronized (mTails) {
			mTails.add(pTail);	
		}
	}
	
	public List<TEntity> getEntities(){
		List<TEntity> entities = new ArrayList<TEntity>();
		for(TEntity entity : mTails){
			entities.add(entity);
		}
		return entities;
	}
}
